﻿using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhonTai.Admin.Core.Entities;
using ZhonTai.Industry.Domain.ProductModel;
using ZhonTai.Industry.Domain.WorkOrderTask;
using ZhonTai.Industry.Domain.WorkStation;

namespace ZhonTai.Industry.Domain.WorkStationRecord
{
    /// <summary>
    /// 产品过站记录
    /// </summary>
    [Table(Name = "prd_work_station_record_{yyyyMM}", AsTable = "CreatedTime=2025-5-1(1 month)")]
    [Index("idx_station_created_result", nameof(StationId) + "," + nameof(CreatedTime) + "," + nameof(Result))]
    public class WorkStationRecordEntity : EntityBase
    {
        /// <summary>
        /// 产品编号
        /// </summary>
        /// <remarks>产品编号</remarks>
        [Column(StringLength = 30)]
        public string? ProductCode { get; set; }

        /// <summary>
        /// 工站Id
        /// </summary>
        /// <remarks>工站Id</remarks>
        public long StationId { get; set; }

        /// <summary>
        /// 班次ID
        /// </summary>
        /// <remarks>班次ID</remarks>
        public long ShiftId { get; set; }

        /// <summary>
        /// 订单Id
        /// </summary>
        /// <remarks>订单Id</remarks>
        public long? OrderId { get; set; }

        /// <summary>
        /// 产品Id
        /// </summary>
        /// <remarks>订单Id</remarks>
        public long? ProductModelId { get; set; }

        /// <summary>
        /// 加工开始时间
        /// </summary>
        /// <remarks>加工开始时间</remarks>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 加工结束时间
        /// </summary>
        /// <remarks>加工结束时间</remarks>
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 循环时间
        /// </summary>
        /// <remarks>循环时间</remarks>
        public double CycleTime { get; set; }

        /// <summary>
        /// 加工结果
        /// </summary>
        /// <remarks>加工结果</remarks>
        [Column(StringLength = 5)]
        public string? Result { get; set; }

        /// <summary>
        /// 载体
        /// </summary>
        /// <remarks>载体</remarks>
        public string? Slot { get; set; }

        /// <summary>
        /// 缺陷代号
        /// </summary>
        /// <remarks>缺陷代号</remarks>
        [Column(StringLength = 20)]
        public string? DefectCode { get; set; }

        /// <summary>
        /// 上传标识
        /// </summary>
        /// <remarks>上传标识</remarks>
        public bool Upload { get; set; }

        /// <summary>
        /// 工站
        /// </summary>
        [Navigate(nameof(StationId))]
        public WorkStationEntity WorkStation { get; set; }

        /// <summary>
        /// 产品类型
        /// </summary>
        [Navigate(nameof(ProductModelId))]
        public ProductModelEntity ProductModel { get; set; }
    }
}